package cc.comac.mom.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import cc.comac.mom.api.EquipParamService;
import cc.comac.mom.bean.EquipParam;
import cc.comac.mom.entity.EquipParamEntity;
import cc.comac.mom.util.ResultBean;

@RestController
@RequestMapping("/EquipParam")
public class EquipParamController {
	@Autowired
	private EquipParamService equipParamService;

	@RequestMapping(value = "/insert",method = RequestMethod.POST)
	public Object insert(@RequestBody EquipParam equipParam) {
		 ResultBean insert = equipParamService.insert(equipParam);
		return insert;
	}

	@RequestMapping(value = "/update",method = RequestMethod.POST)
	public Object update(@RequestBody EquipParam equipParam) {
		ResultBean update = equipParamService.update(equipParam);
		return update;
	}

	@RequestMapping(value = "/batchDelete",method = RequestMethod.POST)
	public Object batchDelete(@RequestBody List<EquipParam> equipParamList) {
		 ResultBean batchDelete = equipParamService.batchDelete(equipParamList);
		return batchDelete;
	}

	// 查询所有
	@RequestMapping(value = "/selectAll",method = RequestMethod.POST)
	public ResultBean selectAll() {
		ResultBean resultBean = new ResultBean(true);
		try {
			List<EquipParamEntity> selectAll = equipParamService.selectAll();
			resultBean.setObject(selectAll);
		}catch(RuntimeException e){
			resultBean.setErrorMessge(e.getMessage());
			return resultBean;
		}
		return resultBean;
	}
}
